<template>
  <div class="app-container">
    <el-form
      :model="queryParams"
      ref="queryRef"
      :inline="true"
      v-show="showSearch"
      label-width="68px"
    >
      <el-form-item label="订单号" prop="orderNo">
        <el-input
          v-model="queryParams.orderNo"
          placeholder="请输入订单号"
          clearable
          style="width: 240px"
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <!-- <el-form-item label="操作人员" prop="createName">
        <el-input
          v-model="queryParams.createName"
          placeholder="请输入操作人员"
          clearable
          style="width: 240px"
          @keyup.enter="handleQuery"
        />
      </el-form-item> -->
      <!-- <el-form-item label="操作时间" style="width: 308px">
        <el-date-picker
          v-model="dateRange"
          value-format="YYYY-MM-DD HH:mm:ss"
          type="daterange"
          range-separator="-"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          :default-time="[
            new Date(2000, 1, 1, 0, 0, 0),
            new Date(2000, 1, 1, 23, 59, 59)
          ]"
        ></el-date-picker>
      </el-form-item> -->
      <el-form-item>
        <el-button type="primary" icon="Search" @click="handleQuery"
          >搜索</el-button
        >
        <el-button icon="Refresh" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>
    <el-scrollbar height="600px">
      <el-timeline>
        <el-timeline-item v-for="(item, index) in operlogList" :key="index">
          <p>
            <text>ID:</text>
            <text> {{ item.id }}</text>
          </p>
          <div style="margin-top: 15px">
            <text>操作人:</text>
            <text style="color: red"> {{ item.createName }}</text>
          </div>
          <p>
            <text>订单号:</text>
            <text> {{ item.orderNo }}</text>
          </p>
          <p>
            <text>操作时间:</text>
            <text>{{ parseTime(item.createTime) }}</text>
          </p>
          <p>
            <text>状态:</text>
            <text style="color: red">{{ item.action }}</text>
          </p>

          <p>
            <text>日志:</text>
            <text>{{ item.logs }}</text>
          </p>
        </el-timeline-item>
      </el-timeline>
    </el-scrollbar>

    <pagination
      v-show="total > 0"
      :total="total"
      v-model:page="queryParams.pageNum"
      v-model:limit="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>

<script setup name="phoneReceiveInfo">
import { list } from '@/api/monitor/phoneReceiveInfo'

const { proxy } = getCurrentInstance()
const operlogList = ref([])
const loading = ref(true)
const showSearch = ref(true)
const total = ref(0)
const dateRange = ref([])
const data = reactive({
  form: {},
  queryParams: {
    pageNum: 1,
    pageSize: 10,
    orderNo: undefined
  }
})

const { queryParams } = toRefs(data)

/** 查询登录日志 */
function getList () {
  loading.value = true
  list(proxy.addDateRange(queryParams.value, dateRange.value)).then(
    response => {
      operlogList.value = response.rows
      total.value = response.total
      loading.value = false
      console.log(operlogList.value, 222)
    }
  )
}

/** 搜索按钮操作 */
function handleQuery () {
  queryParams.value.pageNum = 1
  getList()
}
/** 重置按钮操作 */
function resetQuery () {
  dateRange.value = []
  proxy.resetForm('queryRef')
  queryParams.value.pageNum = 1
  getList()
}

getList()
</script>
